﻿namespace FlexPlatform.BusinessLogic.Validation
{
    using System;

    using FlexPlatform.Shared;
    using FlexPlatform.Shared.Validation;

    public class ValidationResult: IValidationResult
    {
        /// <summary>
        /// Gets or sets the notification associated with the validation result.
        /// </summary>
        public INotification ResultNotification { get; set; }

        public bool ValidationPassed 
        {
            get
            {
                bool passed = false;

                // the validation passed if there is no notification, or the notification level is different than #Error#
                if (ResultNotification == null)
                {
                    passed = true;
                }
                else
                {
                    if (ResultNotification.NotificationLevel != NotificationLevels.Error)
                    {
                        passed = true;
                    }
                }

                return passed;
            }
        }
        
    }
}
